package com.wuzheng.wisgo.sanitation.cloud.controller.dict;


import com.wuzheng.wisgo.sanitation.cloud.repository.entity.dict.BaEnumValue;
import com.wuzheng.wisgo.sanitation.cloud.model.dict.BaEnumValueCriteria;
import com.wuzheng.wisgo.sanitation.cloud.service.dict.EnumValueService;
import com.wuzheng.wisgo.sanitation.framework.base.controller.BaseController;
import com.wuzheng.wisgo.sanitation.framework.core.protocol.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author：sp
 * @date：Created in 2019-10-09
 * @description：字典类型控制器
 * @modified By：
 * @version: 1.0
 */
@RestController
@RequestMapping("/enumValue")
@Api(value = "EnumValueCtrl", tags = "字典类型接口")
public class EnumValueCtrl extends BaseController {

    @Autowired
    private EnumValueService enumValueService;

    /**
     * 获取字典类型列表
     */
    @PostMapping(value = "/fetchList")
    @ApiOperation(value = "获取字典类型列表")
    public Result<List<BaEnumValue>> list(@RequestBody BaEnumValueCriteria baEnumValueCriteria)
    {
        return this.success(enumValueService.selectPage(baEnumValueCriteria));
    }

    /**
     * 新增字典类型
     */
    @PostMapping(value = "/add")
    @ApiOperation(value = "新增字典类型")
    public Result<String> add(BaEnumValue baEnumValue) {
        enumValueService.insert(baEnumValue);
        return this.success("新增成功");
    }

    /**
     * 删除字典类型
     */
    @PostMapping(value = "/delete/{id}")
    @ApiOperation(value = "删除字典类型")
    public Result<String> delete(@PathVariable("id") Long id) {
        enumValueService.deleteById(id);
        return this.success("删除成功");
    }

    /**
     * 修改字典类型
     */
    @PostMapping(value = "/update")
    @ApiOperation(value = "修改字典类型")
    public Result<String> update(BaEnumValue baEnumValue) {
        enumValueService.updateById(baEnumValue);
        return this.success("修改成功");
    }

    /**
     * 获取字典类型
     */
    @GetMapping(value = "/get/{id}")
    @ApiOperation(value = "获取字典类型")
    public Result<BaEnumValue> get(@PathVariable("id") Long id) {
        return this.success(enumValueService.selectById(id));
    }
}

